package com.zalyyh.game.laya

import android.os.Handler
import android.os.Looper
import android.util.Log
import com.zalyyh.game.interfac.GameCallback
import org.json.JSONArray
import org.json.JSONException

object JSBridge {
    var m_Handler = Handler(Looper.getMainLooper())
    var callback:GameCallback? = null
    fun hideSplash() {
        m_Handler.post {  }
    }

    fun setFontColor(color: String) {
        m_Handler.post {  }
    }

    fun setTips(tips: JSONArray) {
        m_Handler.post {
            try {
                val tipsArray = arrayOfNulls<String>(tips.length())
                for (i in 0 until tips.length()) {
                    tipsArray[i] = tips.getString(i)
                }

            } catch (e: JSONException) {
                e.printStackTrace()
            }
        }
    }

    fun bgColor(color: String) {
        m_Handler.post(
            object : Runnable {
                override fun run() {

                }
            })
    }

    fun loading(percent: Double) {
        m_Handler.post(
            object : Runnable {
                override fun run() {

                }
            })
    }

    fun showTextInfo(show: Boolean) {
        m_Handler.post(
            object : Runnable {
                override fun run() {

                }
            })
    }
    fun testString(value: String): String {
        Log.d("JSBridge", "java: $value")
        m_Handler.post {
            if (callback!=null){
                callback!!.oK()
            }
        }
        return "LayaBox"
    }

}